﻿using System.Collections.Generic;
using Core;
using Core.Domain;
using Core.Domain.Lexems;
using Core.SyntaxAnalysis;
using Core.SyntaxAnalysis.Classes;

namespace CoreTests.SyntaxAnalyzerTests
{
    public class SyntaxAnalyzerHelper
    {
        public static Program GetProgramFromString(string source)
        {
            var la = new LexicalAnalyzer();
            List<Lexem> lexems;
            Dictionary<string, int> ids;
            Dictionary<string, int> consts;
            List<CompilerError> errors;
            bool scaned = la.Scan(source, TerminalWords.Keywords, out lexems, out ids, out consts, out errors);
            return new SyntaxAnalyzer().Parse(lexems, ref errors);
        }
    }
}